<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<html>
<head>
    <title>添加班级信息</title>
</head>
<link href="${pageContext.request.contextPath}/static/core/css/style.css">
<body>
<style>
    .modal.fade.in {
        top: 90px;
    }
</style>
<script>
    $(function () {
        selectStudentDisplay();
        selectTeacherDisplay();
        selectEnrolDisplay();
    })

    function commint() {
        $(".add-enrol-form").submit();
    }

    /**
     * 初始化学生下拉菜单
     */
    function selectStudentDisplay() {
        $.ajax({
            url: _baselocation + "/student/studentlist/json",
            type: 'post',
            contentType: 'application/json; charset=UTF-8',
            data: null,//一定不能给转成json字符串传过去 结果会是这样""201922101411""
            dataType: "json",
            success: function (result) {
                // console.log(result)
                if (result != null) {
                    for (var i = 0; i < result.length; i++) {
                        $("#student-id").append('<option value=' + result[i].id + '>' + result[i].name + '</option>');
                    }
                }
            },
        });
    }

    /**
     * 初始化老师下拉菜单
     */
    function selectTeacherDisplay() {
        $.ajax({
            url: _baselocation + "/teacher/teacherlist/json",
            type: 'post',
            contentType: 'application/json; charset=UTF-8',
            data: null,//一定不能给转成json字符串传过去 结果会是这样""201922101411""
            dataType: "json",
            success: function (result) {
                // console.log(result)
                if (result != null) {
                    for (var i = 0; i < result.length; i++) {
                        $("#teacher-id").append('<option value=' + result[i].id + '>' + result[i].teacherName + '</option>');
                    }
                }
            },
        });
    }

    /**
     * 初始化年级下拉菜单
     * /enrol/list
     */
    function selectEnrolDisplay() {
        $.ajax({
            url: _baselocation + "/enrol/enrol/list",
            type: 'post',
            contentType: 'application/json; charset=UTF-8',
            data: null,//一定不能给转成json字符串传过去 结果会是这样""201922101411""
            dataType: "json",
            success: function (result) {
                // console.log(result)
                if (result != null) {
                    for (var i = 0; i < result.length; i++) {
                        $("#current-enrol").append('<option value=' + result[i].enrolName + '>' + result[i].enrolName + '</option>');
                    }
                }
            },
        });
    }
</script>
<!--主容器-->
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="add-enrol-form-content">
                <h1 class="text-center">添加学籍信息</h1>
                <form class="form-horizontal"
                      action="${pageContext.request.contextPath}/census/adddo" id="update-census-form"
                      method="post">
                    <div class="form-group">
                        <label for="student-id" class="col-sm-2 control-label">学籍绑定</label>
                        <div class="col-sm-10">
                            <select class="form-control student-id" id="student-id" name="studentId">
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="target-score" class="col-sm-2 control-label">获得学分</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="targetScore" id="target-score"
                                   placeholder="请输入目标获得学分毕业前必须达到的学分">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="current-score" class="col-sm-2 control-label">已获得学分</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="currentScore" id="current-score"
                                   placeholder="请输入目前获得的学分">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="schoolEvent" class="col-sm-2 control-label">学籍说明</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="schoolEvent" id="schoolEvent"
                                   placeholder="请输入学籍说明">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="graduation-time" class="col-sm-2 control-label">毕业时间</label>
                        <div class="col-sm-10">
                            <input type="date" class="form-control" name="graduationTime"
                                   id="graduation-time">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="current-enrol" class="col-sm-2 control-label">所在年级</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="currentEnrol" id="current-enrol">
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="school-evaluation" class="col-sm-2 control-label">学校评价</label>
                        <div class="col-sm-10">
                            <input type="text" class="form-control" name="schoolEvaluation"
                                   id="school-evaluation"
                                   placeholder="请输入学校评价">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="danger-valid" class="col-sm-2 control-label">是否违纪</label>
                        <div class="col-sm-10">
                            <select class="form-control" name="dangerValid" id="danger-valid">
                                <option value="是">是</option>
                                <option value="否">否</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="teacher-id" class="col-sm-2 control-label">录入老师</label>
                        <div class="col-sm-10">
                            <select class="form-control" id="teacher-id" name="teacherId">

                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="col-sm-offset-5 col-sm-7">
                            <button class="btn btn-info" onclick="commint()">添加</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>

</body>
</html>
